//
//  SexSelectionTableViewController.m
//  FlyGift
//
//  Created by lanou3g on 15/7/16.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "SexSelectionTableViewController.h"

@interface SexSelectionTableViewController ()

@end

@implementation SexSelectionTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationController.navigationBar.translucent = NO;
    self.navigationItem.title = @"选择性别";
    
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth,kP6Height(667-64)) style:UITableViewStyleGrouped];
    
    //取消cell与cell之间的横杠
    self.tableView.separatorStyle = UITableViewCellSelectionStyleNone;
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 2;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *dentifier = @"cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:dentifier];
    if (cell == nil)
    {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:dentifier];
    }
    //取消你所点击的cell的背景颜
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    if (indexPath.row == 0)
    {
        self.boys = [[UILabel alloc]initWithFrame:CGRectMake(kP6width(250/2), 0, kP6width(30), kP6Height(44))];
        _boys.text = @"男孩";
        _boys.font = [UIFont systemFontOfSize:14];
        [cell addSubview:_boys];
    }
    else
    {
        UILabel *line = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, 1)];
        line.backgroundColor = [UIColor blackColor];
        line.alpha = 0.1;
        [cell addSubview:line];
        
        self.girls = [[UILabel alloc]initWithFrame:CGRectMake(kP6width(250/2), 0, kP6width(30), kP6Height(44))];
        _girls.text = @"女孩";
        _girls.font = [UIFont systemFontOfSize:14];
        [cell addSubview:_girls];
    }
    return cell;
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0)
    {
        [[NSUserDefaults standardUserDefaults]setObject:@"男孩" forKey:@"sex"];
    }
    else
    {
        [[NSUserDefaults standardUserDefaults]setObject:@"女孩" forKey:@"sex"];
    }
    
    [self.navigationController popViewControllerAnimated:YES];
}





@end

